<!DOCTYPE html>
<html>

  <head>
    <title>SSH Terminal</title>
    <style>
      html {
        background: #010;
        font-family: courier;
        font-size: 12px;
      }
      .terminal {
        width: 630px;
        height: 450px;
        border: none;
      }
      .terminal-cursor {
        color: #000;
        background: #f0f0f0;
      }
    </style>
  </head>

  <body>
    <script>
      const {ipcRenderer} = require('electron');
      var Terminal = require('./term.js'),
          timer;

      var term = new Terminal({
        geometry:[81, 31],
        screenKeys: true,
        style: true,
        cursorBlink: true
      });

      term.on('data', function(data) {
        ipcRenderer.send('stdin', data);
      });

      term.on('title', function(title) {
        document.title = title;
      });

      term.open(document.body);

      ipcRenderer.on('grayscale', function() {

        term.colors = [
          '#000000',
          '#ffffff',
          '#ffffff',
          '#ffffff',
          '#ffffff',
          '#ffffff',
          '#ffffff',
          '#ffffff',
          '#ffffff',
          '#ffffff',
          '#ffffff',
          '#ffffff',
          '#ffffff',
          '#ffffff',
          '#ffffff',
          '#ffffff'
        ];

      });

      ipcRenderer.on('stdout', function(e, data) {
        term.write(data);
      });

      ipcRenderer.on('stderr', function(e, data) {
        term.write(data);
      });

      ipcRenderer.on('disconnect', function() {
        ipcRenderer.send('disconnect', true);
        term.reset();
      });

    </script>

  </body>

</html>
